package books.CoreJavaVolumeII.Chaper1;

import java.util.stream.*;

/**
 * @Description
 * @Author bloodcolding
 * @Date 2021/01/24 1:54 PM
 */
public class UseStream {
    public static void main(String[] args) {
        IntStream stream = IntStream.range(1, 100);
//        stream.forEach(a -> System.out.println(a));
//        System.out.println(stream.findAny());
//        System.out.println(stream.findFirst());
//        System.out.println(stream.summaryStatistics().getAverage());

        Stream<String> strStream = Stream.of("aaa", "222", "sdfsfs");
//        System.out.println(strStream.collect(Collectors.joining(",","prefix","suffix")));
        // prefixaaa,222,sdfsfssuffix
        System.out.println(strStream.collect(Collectors.groupingBy(String::length)));
        // {3=[aaa, 222], 6=[sdfsfs]}
//        System.out.println(strStream.collect(Collectors.partitioningBy(a->a.length() > 3)));
        // {false=[aaa, 222], true=[sdfsfs]}
    }
}
